package lily.phs.healthedu;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
//import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.GridView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import lily.phs.urh.R;

public class heliyongyao extends Activity {
	
	private Animation in_left;
	private Animation in_right;
	private Animation out_left;
	private Animation out_right;
	private TextView trainning_title;
	private TextView trainning_content;
	//private GridView gv;
	Button leftBtn;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.trainning_all);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.i_title);
        
        out_left = AnimationUtils.loadAnimation(this,R.anim.anim_slide_out_left);
        out_right = AnimationUtils.loadAnimation(this,R.anim.anim_slide_out_right);
        in_right = AnimationUtils.loadAnimation(this, R.anim.anim_slide_in_right);
        in_left = AnimationUtils.loadAnimation(this,R.anim.anim_slide_in_left);
        trainning_title = (TextView)this.findViewById(R.id.trainning_title);
        trainning_content = (TextView)this.findViewById(R.id.trainning_content);
        
        leftBtn = (Button) findViewById(R.id.title_left_btn);
        final Button rightBtn = (Button) findViewById(R.id.title_right_btn);
        final Button rightBtn2 = (Button) findViewById(R.id.title_right_btn2);
        leftBtn.setText("后退");
        leftBtn.setOnClickListener(new OnClickListener(){

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				finish();
				overridePendingTransition(R.anim.anim_slide_in_left,R.anim.anim_slide_out_right);
			}
        	
        });
        rightBtn.setVisibility(View.GONE);
        rightBtn2.setVisibility(View.GONE);

    	Bundle bd = getIntent().getExtras();
    	int child = bd.getInt("child");
    	switch(child)
    	{
    	case 0:
    		trainning_title.setText(getResources().getString(R.string.heliyongyao_title1));
    		trainning_content.setText(getResources().getString(R.string.heliyongyao_content1));
    		break;    		
    	case 1:
    		trainning_title.setText(getResources().getString(R.string.heliyongyao_title2));
    		trainning_content.setText(getResources().getString(R.string.heliyongyao_content2));
    		break;
    	case 2:
    		trainning_title.setText(getResources().getString(R.string.heliyongyao_title3));
    		trainning_content.setText(getResources().getString(R.string.heliyongyao_content3));
    		break;
    	case 3:
    		trainning_title.setText(getResources().getString(R.string.heliyongyao_title4));
    		trainning_content.setText(getResources().getString(R.string.heliyongyao_content4));
    		break;
    	case 4:
    		trainning_title.setText(getResources().getString(R.string.heliyongyao_title5));
    		trainning_content.setText(getResources().getString(R.string.heliyongyao_content5));
    		break;
    	case 5:
    		trainning_title.setText(getResources().getString(R.string.heliyongyao_title6));
    		trainning_content.setText(getResources().getString(R.string.heliyongyao_content6));
    		break;
    	case 6:
    		trainning_title.setText(getResources().getString(R.string.heliyongyao_title7));
    		trainning_content.setText(getResources().getString(R.string.heliyongyao_content7));
    		break;
    	case 7:
    		trainning_title.setText(getResources().getString(R.string.heliyongyao_title8));
    		trainning_content.setText(getResources().getString(R.string.heliyongyao_content8));
    		break;
    	}
        

        
        //menubar
       /* gv = (GridView)this.findViewById(R.id.menu);
		String[] menubar = new String[]{"首页", "后退",  "帮助", "菜单"  };
		int[] menuIcon = new int[]{
				R.drawable.controlbar_homepage,
				R.drawable.controlbar_backward_enable,
				R.drawable.controlbar_window, 
				R.drawable.controlbar_showtype_list, };
		ArrayList<Map<String , Object>> gv_array = new ArrayList<Map<String , Object>>();
		for(int i=0;i<menubar.length;i++){
			Map<String , Object> gv_item = new HashMap<String , Object>();
			gv_item.put("menuIcon", menuIcon[i]);
			gv_item.put("menuOrder", menubar[i]);
			System.out.println("menuOrder="+menubar[i]);
			gv_array.add(gv_item);
			//System.out.println("gv_item="+gv_item.toString());
		}
		SimpleAdapter gvAdapter = new SimpleAdapter(heliyongyao.this, gv_array, R.layout.griditem, 
				new String[]{"menuIcon","menuOrder"}, 
				new int[]{R.id.gv_icon,R.id.gv_text});
		gv.setAdapter(gvAdapter);
		gv.setOnItemClickListener(new OnItemClickListener(){

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3) {
				// TODO Auto-generated method stub
				switch(arg2){
				case 0:{//主界面
					startActivity(new Intent(heliyongyao.this,MainActivity.class));
					overridePendingTransition(R.anim.anim_slide_in_left,R.anim.anim_slide_out_right);
					finish();
					break;
				}
				case 1:{//back
					finish();
					overridePendingTransition(R.anim.anim_slide_in_left,R.anim.anim_slide_out_right);
					break;
				}
				case 2:{//
					
					break;
				}
				}
			}			
		});  */   

        }
//	@Override
//	public boolean onKeyDown(int keyCode, KeyEvent event) {
//		// TODO Auto-generated method stub
//		startActivity(new Intent(Vaccin1.this,VaccinList1.class));
//		overridePendingTransition(R.anim.anim_slide_in_left,R.anim.anim_slide_out_right);
//		finish();
//		return super.onKeyDown(keyCode, event);
//	}
//	

}

